# 最小CMake版本
cmake_minimum_required(VERSION 3.20)

# 项目名称
project(VTool)

# 编译选项
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/source-charset:UTF-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:UTF-8>")


# 输出路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)

# 源文件路径
file(GLOB_RECURSE SOURCES_1 ${PROJECT_SOURCE_DIR}/src/*.c**)
file(GLOB_RECURSE SOURCES_2 ${PROJECT_SOURCE_DIR}/thirdparty/*.c**)
list(APPEND SOURCES_LIST ${SOURCES_1} ${SOURCES_2})

# 库文件路径
file(GLOB_RECURSE LIBS ${PROJECT_SOURCE_DIR}/libs/*.lib)
file(GLOB_RECURSE LIBS_DIR ${PROJECT_SOURCE_DIR}/libs)



# 头文件路径
set(
    INCLUDE_DIRECTORIES 
    ${PROJECT_SOURCE_DIR}/header
    ${PROJECT_SOURCE_DIR}/thirdparty
    ${PROJECT_SOURCE_DIR}/thirdparty/duckx
    ${PROJECT_SOURCE_DIR}/thirdparty/zip 
    ${PROJECT_SOURCE_DIR}/thirdparty/pugixml
    ${PROJECT_SOURCE_DIR}/thirdparty/xlnt
    ${PROJECT_SOURCE_DIR}/thirdparty/nlohmann
)

# 包含头文件路径
include_directories(${INCLUDE_DIRECTORIES})

# 生成可执行文件
add_executable(${PROJECT_NAME} ${SOURCES_1})
# 编译选项

if(MSVC)
    # 取消byte符号的歧义
    add_compile_options(/DNOMINMAX)  # 防止Windows头文件定义min/max宏
    add_compile_options(/D_CRT_SECURE_NO_WARNINGS)
    add_compile_options(/D_SCL_SECURE_NO_WARNINGS)
    # 禁用Windows的byte定义
    add_compile_definitions(NOBYTE)
    
    # 或者使用命令行定义
    target_compile_options(${PROJECT_NAME} PRIVATE /DNOBYTE /EHsc)
endif()

# 链接库文件    
link_directories(${LIBS_DIR})
target_link_libraries(${PROJECT_NAME} ${LIBS})




